<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>9直接发送axios请求</title>
    <script src="./lib/axios.js"></script>
    <script src="./lib/vue-2.6.12.js"></script>
    <link rel="stylesheet" href="./lib/bootstrap.css" />
  </head>
  <body>
    <div id="app">
      <table class="table table-bordered table-hover table-striped">
        <thead>
          <th>id</th>
          <th>book name</th>
          <th>author</th>
          <th>publisher</th>
        </thead>
        <tbody>
          <tr v-for="item in list" :key="item.id">
            <td>{{item.id}}</td>
            <td>{{item.bookname}}</td>
            <td>{{item.author}}</td>
            <td>{{item.publisher}}</td>
          </tr>
        </tbody>
      </table>
      <input type="text" v-model.trim="inputInfo" placeholder="输入id查找"/>
      <button id="getInfo" @click="list1">发送请求获取书籍列表</button>
    </div>
    <script>
      const vm = new Vue({
        el: "#app",
        data: {
          list:[],
          inputInfo:""
        },
        methods: {
            async list1() {
                const { data: res } = await axios.get(
                  "http://www.liulongbin.top:3006/api/getbooks",
                  {
                    params: {
                        
                        //id:this.inputInfo
                    },
                  }
                );
                console.log(res.data) ;
                //console.log(this.inputInfo)
                this.list =  res.data;
            
          },
        },
      });
    </script>
  </body>
</html>
